<%--
  Created by IntelliJ IDEA.
  User: Xun
  Date: 2022/4/23
  Time: 12:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>易买网 - 首页</title>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <script type="text/javascript" src="scripts/function.js"></script>
    <script type="text/javascript" src="../js/jQery-3.6.0.min.js"></script>
</head>
<body>
<div id="header" class="wrap">
    <div id="logo"><img src="images/logo.gif"/></div>
    <div class="help"><a href="/ListShoppingCar" class="shopping">购物车</a><a href="login.html">登录</a><a href="register.html">注册</a><a
            href="guestbook.html">留言</a></div>
    <div class="navbar">
        <ul class="clearfix">
            <li class="current"><a href="#">首页</a></li>
            <li><a href="#">图书</a></li>
            <li><a href="#">百货</a></li>
            <li><a href="#">品牌</a></li>
            <li><a href="#">促销</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="wrap">
        <ul class="clearfix">
            <li class="first"><a href="#">分类</a></li>
            <c:forEach items="${childCategoryList}" var="child">
                <li><a href="/ShowProductServlet?childid=${child.childid}">${child.childname}</a></li>
            </c:forEach>
            <li class="last"><a href="#">Investor Relations</a></li>
        </ul>
    </div>
</div>
<div id="position" class="wrap">
    您现在的位置：<a href="index.html">易买网</a> &gt; 购物车
</div>
<div class="wrap">
    <div id="shopping">
        <form>
            <table>
                <tr>
                    <th>商品名称</th>
                    <th>商品价格</th>
                    <th>购买数量</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${list}" var="list">
                    <tr id="product_id_1">
                        <td class="thumb"><img src="images/product/0_tiny.gif"/>
                            <a href="/ProductViewServlet?id=${list.id}">
                                    ${list.name}
                            </a></td>
                        <td class="price" id="price_id_1">
                            <span>￥${list.price*list.quantity}</span>
                            <input type="hidden" value="99"/>
                        </td>
                        <td class="number">
                            <dl>
                                <dt><input id="number_id_1" type="text" name="number" value="${list.quantity}" /></dt>
                            </dl>
                        </td>
                        <td class="delete"><a href="/delShoppingCar?id=${list.id}">删除</a></td>
                    </tr>
                </c:forEach>
            </table>
            <div class="button"><input id="order" onclick="addorder()" type="submit" value=""/></div>
        </form>
    </div>
    <script type="text/javascript">
        document.write("Cookie中记录的购物车商品ID：" + getCookie("product") + "，可以在动态页面中进行读取");
    </script>
</div>
<div id="footer">
    Copyright &copy; 2010 All Rights Reserved. 京ICP证1000001号
</div>
</body>
<script>
    function addorder(){
        $.ajax({
            type:"post",
            url:"admin/addorder",
            success:function (data){
                console.log(data)
                if (data=="true"){
                    document.location.href ="/shopping-result.html";
                }
            }
        })

    }

</script>
</html>
